﻿<%@ Page Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="BottleProductionList.aspx.cs" Inherits="PMS.UI.PM.BottleProductionList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            //   $('#btnModify').linkbutton('disable');
            $("#tbList").datagrid({
                url: '/Logic/PM/BottleProductionAjax.aspx?method=GetBottleProductionList',
                loadMsg: '数据加载中请稍后……',
                fitColumns: false,
                pagination: true,
                queryParams: com.serializeSearchArray("form1"),
                rownumbers: true,
                idField: "ID",
                singleSelect: true,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                  {
                      field: 'State', title: '状态', align: "center", width: 60,
                      formatter: function (value, row, Index) {
                          return com.getArrayText(StaticCombo.BottleState, value);
                      }
                  },
                 { field: 'SerialCode', title: '流水号', align: "center", width: 100 },
                 {
                     field: 'BottleID', title: '气瓶编号', align: "center", width: 100, editor: {
                         type: "combogrid",
                         options: {
                             required: true,
                             loadMsg: '检索中...',
                             panelWidth: 450,
                             pagination: true,
                             rownumbers: true,
                             idField: 'ID',
                             mode: 'remote',
                             textField: 'BottleCode',
                             url: '/Logic/BD/BottleAjax.aspx?method=GetBottleInfoByQ',
                             columns: [[
                             { field: 'BottleCode', title: '气瓶编号', width: 160 },
                             { field: 'BottleAlloy', title: '材质', width: 200 },
                             { field: 'BottleVolume', title: '气瓶容积', width: 60 }
                             ]]
                         }
                     },
                     formatter: function (value, row, index) {
                         return row.BottleCode;
                     }
                 },
                  { field: 'ProductName', title: '产品名称', sortable: true, align: "center", width: 100 },
                  {
                      field: 'TechParams', title: '技术参数', align: "center", width: 200,
                      formatter: function (value, row, index) {
                          //文本超出列宽自动换行
                          //鼠标放在文本处自动显示tooltip
                          return '<span title=' + value + '>' + value + '</span>';
                          //return '<div style="width=100px;word-break:break-all; word-wrap:break-word;white-space:pre-wrap;">' + value + '</div>';
                      }
                  }
                ]],
                columns: [[
                    { field: 'FillDate', title: '投产日期', align: "center", width: 120 },

                  { field: 'CompletedDate', title: '配气完成日期', align: "center", width: 120 },


                {
                    field: 'BottleAlloy', title: '气瓶材质', align: "center", width: 100
                },
                  { field: 'BottleVolume', title: '规格（L）', align: "center", width: 60 },
                  {
                      field: 'ProductOrderCode', title: '生产订单号 ', align: "center", width: 100
                  },
                  {
                      field: 'QuotationCode', title: '报价单号 ', align: "center", width: 100
                  },
                   {
                       field: 'GBID', title: '国标号', align: "center", width: 120, editor: {
                           type: "combogrid",
                           options: {
                               required: true,
                               panelWidth: 650,
                               pagination: true,
                               rownumbers: true,
                               loadMsg: '检索中...',
                               idField: 'ID',
                               mode: 'remote',
                               textField: 'GBCode',
                               url: '/Logic/BD/GBAjax.aspx?method=GetGBInfoByQ',
                               columns: [[
                               { field: 'GBCode', title: '国标号', width: 160 },
                               { field: 'GasName', title: '名称', width: 200 },
                               { field: 'Range', title: '范围', width: 200 },
                               { field: 'Uncertainty', title: '不确定度（%）', width: 80 }
                               ]]
                           }
                       },
                       formatter: function (value, row, index) {
                           return row.GBCode;
                       }
                   },
                 { field: 'Uncertainty', title: '不确定度', align: "center", width: 60 },
                  {
                      field: 'Pressure', title: '压力(MPa)', align: "center", width: 80,
                      editor: {
                          type: "textbox"
                      }
                  },

                  { field: 'PersonID', title: '配气师', align: "center", width: 110 },

                {
                    field: 'Note', title: '备注', align: "center", width: 100,
                    editor: {
                        type: "textbox"
                    }
                }
                ]],
                onAfterEdit: function (rowIndex, rowData, changes) {
                    if (editAction == "edit") {
                        com.ajax({
                            url: "/Logic/PM/BottleProductionAjax.aspx?method=EditBottleProduction",
                            data: rowData,
                            success: function (data) {
                                com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                            }
                        });
                    }
                    editRow = undefined;
                },
                onCancelEdit: function (rowIndex, rowData) {
                    $("#tbList").datagrid("rejectChanges");
                },
            });

        });

    </script>

    <script type="text/javascript">
        editRow = undefined;
        editAction = undefined;
        //保存
        function funcSave() {
            $('#tbList').datagrid('endEdit', editRow);
        }

        //编辑
        function funcEdit() {
            var row = $('#tbList').datagrid('getSelected');

            if (row) {
                if (row.State != '0') {
                    com.message("error", "气瓶当前状态不允许编辑");
                    return;
                }

                if (editRow != undefined) {
                }
                else {
                    var index = $("#tbList").datagrid('getRowIndex', row);
                    $("#tbList").datagrid('beginEdit', index);
                    editAction = "edit";
                    editRow = index;
                    rowData = $("#tbList").datagrid("getSelected");
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }

        //取消编辑
        function funcCancel() {
            $('#tbList').datagrid("cancelEdit", editRow);
            editRow = undefined;
            editAction = undefined;
        }

        //查询
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }


        //重置
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }

        //删除
        function funcRemove() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                if (row.State == '4') {
                    com.message("error", "当前气瓶已发货完成，无法删除！");
                   
                }
                else {
                    var msg = "当前气瓶已进入 生产 状态，删除该气瓶将同时删除掉该气瓶相应的计算浓度信息与分析浓度信息，您确定删除该气瓶吗？";
                    $.messager.confirm('确认对话框', msg, function (r) {
                        if (r) {
                            com.ajax({
                                url: '/Logic/PM/BottleProductionAjax.aspx?method=DelBottleProduction',
                                data: { ID: row.ID },
                                success: function (data) {
                                    com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); $("#tbList").datagrid('clearSelections'); })
                                }
                            });
                        }
                    });
                }
            }
        }

        //普通多元组分配气
        function funcMakeGas() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {

                top.wrapper.addTab("普通气瓶配气", "/UI/PM/GeneralAssingGas.aspx?action=assign&BarCode=" + row.SerialCode);

            }
            else {
                com.message("information", "请选中一行");
            }
        }

        //超级多元组分配气
        function funcMakeMultiGas() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {

                top.wrapper.addTab("超多元配气", "/UI/PM/MutilAssingGas.aspx?action=assign&BarCode=" + row.SerialCode);

            }
            else {
                com.message("information", "请选中一行");
            }
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <div id="master" class="container_16" style="height: auto">
            <form id="form1">
                <div class="grid_2 sealbl" style="text-align: right;">
                    状态 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="State" name="State" data-cp="=" data-options="valueField:'value',textField:'text',data:StaticCombo.BottleStateQuery,panelHeight:'auto'" />
                </div>

                <div class="grid_2 sealbl" style="width: 100px">
                    生产订单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductOrderCode" name="ProductOrderCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    产品名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductName" name="ProductName" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    气瓶编号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="BottleCode" name="BottleCode" data-cp="co" />
                </div>
                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    流水号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="SerialCode" name="SerialCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="width: 100px">
                    投产日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startFillDate" name="startFillDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endFillDate" name="endFillDate" data-cp="str<=" class="easyui-datebox" />
                </div>
                 <div class="grid_2 sealbl" style="width: 100px">
                    报价单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="QuotationCode" name="QuotationCode" data-cp="co" />
                </div>
            </form>
        </div>
        <table id="tbList" title="气瓶配气表 " style="width: 100%">
        </table>
    </div>
</asp:Content>
